package router

import (
	"duoke/controller/console"
	"duoke/middleware"
	"github.com/gin-gonic/gin"
)

func LoadConsole(r *gin.Engine) {
	r.POST("console/account/login", console.Account.Login)
	r.POST("console/account/logout", console.Account.Logout)
	r.POST("console/setting/site", console.Setting.Site)
	r.POST("console/area/index", console.Area.Area)
	// 鉴权
	consoleRouter := r.Group("console")
	{
		// 管理员鉴权中间件
		consoleRouter.Use(middleware.ConsoleAuth())
		// 仪表盘
		consoleRouter.POST("dashboard/index", console.Dashboard.Index)
		// 账户
		consoleRouter.POST("account/list", console.Account.List)
		consoleRouter.POST("account/del", console.Account.Del)
		consoleRouter.POST("account/save", console.Account.Save)
		consoleRouter.POST("account/state", console.Account.State)
		// 设置
		consoleRouter.POST("setting/info", console.Setting.Info)
		consoleRouter.POST("setting/save", console.Setting.Save)
	}
	consoleRouter2 := r.Group("console")
	{
		// 登录鉴权中间件
		consoleRouter2.Use(middleware.AccountAuth())
		// 账户基础信息
		consoleRouter2.POST("account/info", console.Account.Info)
		consoleRouter2.POST("account/info_update", console.Account.UpdateInfo)
		// 上传
		consoleRouter2.POST("upload/file", console.Upload.File)
		consoleRouter2.POST("upload/cert", console.Upload.Cert)
		consoleRouter2.POST("upload/file_list", console.Upload.FileList)
		consoleRouter2.POST("upload/file_del", console.Upload.FileDel)
		consoleRouter2.POST("upload/group_list", console.Upload.GroupList)
		consoleRouter2.POST("upload/group_del", console.Upload.GroupDel)
		consoleRouter2.POST("upload/group_save", console.Upload.GroupSave)
		consoleRouter2.POST("upload/group_move", console.Upload.GroupMove)
		consoleRouter2.POST("upload/fragment_upload", console.Upload.FragmentUpload)

		// 系统接口
		consoleRouter2.POST("upgrade/authorize", console.Upgrade.Authorize)
		consoleRouter2.POST("upgrade/upgrade", console.Upgrade.Upgrade)
		consoleRouter2.POST("upgrade/progress", console.Upgrade.Progress)
		consoleRouter2.Any("upgrade/reboot", console.Upgrade.Reboot)
	}
}
